package pages;

import org.openqa.selenium.By;
import org.testng.Assert;
import ui_test.TestData;
import utils.Log4Test;

/**
 * Created with IntelliJ IDEA.
 * User: u
 * Date: 7/21/14
 * Time: 3:23 PM
 * To change this template use File | Settings | File Templates.
 */
public class WishListPage extends GeneralPage {
    protected By newListCreationButton = By.xpath("//button[@id='create_wishlist_button']");
    protected By newWishField = By.xpath("//input[@id='wishlist_create_input']");
    protected By submitButton = By.xpath("//input[@class='submit']");
    protected By wishtitle = By.xpath("//div[@class='wishlist-i-title']/h3");
    protected By searchField = By.xpath("//input[@class='header-search-input-text']");
    protected By searchButton = By.xpath("//button[@class='btn-link-i']");

    public void wishListCreation() {
        Log4Test.info("wishList creation");
        webDriver.findElement(newListCreationButton).click();
    }

    public void firstWishCreation() {
        Log4Test.info("first wish sending");
        webDriver.findElement(newWishField).sendKeys(TestData.firstProductName);
        webDriver.findElement(submitButton).click();
    }

    public void wishAppearanceVerifying() {
        Log4Test.info("first wish appearance verify");
        Assert.assertEquals(TestData.firstProductName, webDriver.findElement(wishtitle).getText());
    }

    public SearchResultPage searchMaking() {
        Log4Test.info("first product searching");
        webDriver.findElement(searchField).sendKeys(TestData.firstProductName);
        webDriver.findElement(searchButton).click();
        return new SearchResultPage();

    }
}
